class Solution {
public:
    vector<int> searchRange(vector<int>& nums, int target) {
      int l=0,r=nums.size()-1;
      int mid;
      if(r==-1){
        return vector<int>{-1,-1};
      }
      while(l<r){
          mid=(l+r)/2;
        if(nums[l]==nums[r]&&nums[l]==target){
             return vector<int>{l,r};
        }
        if(nums[mid]>=target&&nums[r]!=target){
          r--;
        }else{
          if(nums[l]!=target){
            l++;
          }
        }
      }
      if(nums[l]==target){
          return vector<int>{l,r};
      }
      return vector<int>{-1, -1};
    }
};
